﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="mylist.aspx.cs" Inherits="jnxc.Web.teaminfo.mylist" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">    
    <script src="../Script/sitedata.js"></script>
    <script src="../Script/combobox.js"></script>
    <script src="../Script/city.js"></script>
    

     <script type="text/javascript">
         var provinceName;
         var cityName;
         var arrCity;
         var areaName;
         var arrArea;
         $(function () {
             InitGird();
             InitSelect();
         });
         Date.prototype.pattern = function (fmt) {
             var o = {
                 "M+": this.getMonth() + 1, //月份        
                 "d+": this.getDate(), //日        
                 "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时        
                 "H+": this.getHours(), //小时        
                 "m+": this.getMinutes(), //分        
                 "s+": this.getSeconds(), //秒        
                 "q+": Math.floor((this.getMonth() + 3) / 3), //季度        
                 "S": this.getMilliseconds() //毫秒        
             };
             var week = {
                 "0": "/u65e5",
                 "1": "/u4e00",
                 "2": "/u4e8c",
                 "3": "/u4e09",
                 "4": "/u56db",
                 "5": "/u4e94",
                 "6": "/u516d"
             };
             if (/(y+)/.test(fmt)) {
                 fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
             }
             if (/(E+)/.test(fmt)) {
                 fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f" : "/u5468") : "") + week[this.getDay() + ""]);
             }
             for (var k in o) {
                 if (new RegExp("(" + k + ")").test(fmt)) {
                     fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                 }
             }
             return fmt;
         }
         var Common = {

             //EasyUI用DataGrid用日期格式化
             TimeFormatter: function (value, rec, index) {
                 if (value == undefined) {
                     return "";
                 }
                 /*json格式时间转js时间格式*/
                 value = value.substr(1, value.length - 2);
                 var obj = eval('(' + "{Date: new " + value + "}" + ')');
                 var dateValue = obj["Date"];
                 if (dateValue.getFullYear() < 1900) {
                     return "";
                 }
                 var val = dateValue.pattern("yyyy-MM-dd HH:mm");
                 return val;
             },
             DateTimeFormatter: function (value, rec, index) {

                 if (value == null || value == '') {
                     return '';
                 }
                 var dt;
                 if (value instanceof Date) {
                     dt = value;
                 }
                 else {
                     dt = new Date(value);
                     if (isNaN(dt)) {
                         value = value.replace(/\/Date\((-?\d+)\)\//, '$1'); //标红的这段是关键代码，将那个长字符串的日期值转换成正常的JS日期格式
                         dt = new Date(value);
                         //dt.setTime(value);
                     }
                 }
                 return dt.pattern("yyyy年M月d日");
             },

             //EasyUI用DataGrid用日期格式化
             DateFormatter: function (value, rec, index) {
                 if (value == undefined) {
                     return "";
                 }
                 /*json格式时间转js时间格式*/
                 value = value.substr(1, value.length - 2);
                 var obj = eval('(' + "{Date: new " + value + "}" + ')');
                 var dateValue = obj["Date"];
                 if (dateValue.getFullYear() < 1900) {
                     return "";
                 }

                 return dateValue.pattern("yyyy-MM-dd");
             }
         };
         //初始化表格
         function InitGird() {
             $('#tt').datagrid({
                 title: '防区队伍列表', //表格标题
                 url: 'GetTeam.ashx', //请求数据的页面
                 sortName: 'tbh', //排序字段
                 idField: 'tid', //标识字段,主键
                 iconCls: '', //标题左边的图标
                 width: '100%', //宽度
                 //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                 nowrap: false, //是否换行，True 就会把数据显示在一行里
                 striped: true, //True 奇偶行使用不同背景色
                 collapsible: false, //可折叠
                 sortOrder: 'desc', //排序类型
                 remoteSort: true, //定义是否从服务器给数据排序
                 fitColumns: true,
                 method: 'post',
                 columns: [[                    
                     { title: '编号', field: 'tbh', width: 80, sortable: true },
                     { title: '姓名', field: 'tname', width: 80 },
                     { title: '性别', field: 'tsex', width: 40 },
                     { title: '身份证号', field: 'tno', width: 180 },
                     { title: '手机', field: 'tphone', width: 100 },
                     { title: '邮箱', field: 'temail', width: 150 },
                     { title: '职务', field: 'tpost', width: 100 },
                     { title: '负责区域', field: 'tarea', width:150 },
                     { title: '职称', field: 'tjob', width: 100 },
                     { title: '地址', field: 'madd', width: 100 },
                     { title: '学历', field: 'tedu', width: 80 },
                     {
                         title: '入职时间', field: 'ttime', width: 150, formatter: function (value, row, index) {
                             if (value != "") {
                                 //return Common.DateTimeFormatter(value, row, index);
                                 //2014-12-15 0:00:00 new Date('2012-05-10 10:10:21'); 
                                 if (value.indexOf("-") != -1)
                                     value = value.replace(/-/g, "/");
                                     //value = value.replace(/(\d{4})-(\d{2})-(\d{2})T(.*)?\.(.*)/, "$1/$2/$3 $4")
                                 //new Date(a)
                                 return new Date(value).pattern("yyyy年M月d日");
                             }
                             //return value;
                         }

                     },
                     { title: '荣誉', field: 'thonour', width: 150 },
                     { title: '照片', field: 'tpic', width: 150, formatter: function (value, row, index) { return '<img height=32 width=32 src="' + row.tpic + '" />'; } }
                 ]],
                 toolbar: "#tab_toolbar",
                 queryParams: { "action": "querymy" },
                 pagination: true, //是否开启分页
                 pageNumber: 1, //默认索引页
                 pageSize: 20, //默认一页数据条数
                 rownumbers: true //行号
             });


         }
         function InitSelect() {
             loadNameEdit();            
             $.ajax({
                 type: "post",
                 dataType: "json",
                 url: "../admin/getinfo.ashx?action=level",
                 success: function aa(data) {
                     $('#level').val(data[0].level);
                     if (data[0].level == 3) {
                         provinceName = data[0].province;
                         $('#uprovince').combobox('setValue', data[0].province);
                         $("#dprovince").hide();
                     }
                     if (data[0].level == 2) {
                         provinceName = data[0].province;
                         $('#uprovince').combobox('setValue', data[0].province);
                         cityName = data[0].city;
                         $('#ucity').combobox('setValue', data[0].city);
                         $("#dprovince").hide();
                         $("#dcity").hide();
                     }
                     if (data[0].level == 1) {
                         provinceName = data[0].province;
                         $('#uprovince').combobox('setValue', data[0].province);
                         cityName = data[0].city;
                         $('#ucity').combobox('setValue', data[0].city);
                         areaName = data[0].county;
                         $('#ucounty').combobox('setValue', data[0].county);
                         $("#dprovince").hide();
                         $("#dcity").hide();
                         $("#dcounty").hide();
                     }
                 }
             });
         }
         function getQueryParams(queryParams) {
             var uprovince = $("#uprovince").combobox("getValue");
             var ucity = $("#ucity").combobox("getValue");
             var uname = $("#uname").val();
             var utruename = $("#utruename").val();
             
             var ucounty = $("#ucounty").combobox("getValue");             
             var uunit = $("#uunit").val();
             queryParams.uprovince = uprovince;
             queryParams.ucity = ucity;
             queryParams.uname = uname;
             queryParams.ucounty = ucounty;
             
             queryParams.uunit = uunit;
             queryParams.utruename = utruename;
             return queryParams;
         }
         //增加查询参数，重新加载表格  
         function reloadgrid() {
             //查询参数直接添加在queryParams中      
             var queryParams = $('#tt').datagrid('options').queryParams;
             getQueryParams(queryParams);
             $('#tt').datagrid('options').queryParams = queryParams;
             $("#tt").datagrid('reload');
         }
      
    </script>
    <style>
        .fitem {            
            float:left;
        }
            .fitem label {
                width:30px;
                line-height:24px;
            }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table id="tt">
    </table>
    <div id="tab_toolbar" style="padding: 4px;">
        <table cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>
                <td style="padding-left: 2px">                    
                     <div class="fitem"> 
                          <div class="fitem" id="dprovince">
                <label>省：</label>
                <input id="uprovince" name="uprovince" class="easyui-combobox" data-options="width:'100'"/>
            </div>
            <div class="fitem" id="dcity">
                <label>市：</label>
                <input id="ucity" name="ucity" class="easyui-combobox" data-options="width:'100'"/>
            </div>
            <div class="fitem" id="dcounty">
                <label>县：</label>
                <input id="ucounty" name="ucounty" class="easyui-combobox" data-options="width:'100'" />
            </div>  

                     </div>                       

                        <div style="padding:2px;float:left;">
          姓名：   
           <input id="uname" class="easyui-validatebox" style="width:80px;"/> 职称：   
           <input id="utruename" class="easyui-validatebox" style="width:80px;"/> 
                            学历：<input id="uunit" class="easyui-validatebox" style="width:80px;"/> 
                           
          
           <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reloadgrid()">查找</a> 
                             </div>  
       
                </td>
            </tr>
        </table>
    </div>   
</asp:Content>